package com.learning.spring.cloud.ms.consumer.movie.controller;

import com.learning.spring.cloud.ms.consumer.movie.entity.User;
import com.learning.spring.cloud.ms.consumer.movie.feign.UserFeignService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: MovieController
 * Description:
 * Date: 2019/5/31 10:42 【需求编号】
 *
 * @author Sam Sho
 * @version V1.0.0
 */
@Slf4j
@RestController
@RequestMapping("movie")
public class MovieController {


    @Autowired
    private UserFeignService userFeignService;

    /**
     * 测试地址http://localhost:8010/movie/user/1
     * <p>
     * 监控地址-http://localhost:8010/hystrix.stream
     * 1- hystrix 的 hystrix-metrics-event-stream 模块，可以将监控的指标信息以text/evebt-stream 的格式暴露给外部系统
     * 2- spring-cloud-starter-netflix-hystrix 包含了 hystrix-metrics-event-stream 模块
     * 3- 默认feign 集成hystrix熔断是不需要添加 @EnableHystrix注解的，但是如需监控则需要手动添加
     * 4. 依赖于端点监控的 spring-boot-actuator
     * <p>
     * <p>
     * 需要添加pom
     *
     * @param id
     * @return
     */
    @GetMapping("/user/{id}")
    public User findById(@PathVariable Long id) {
        return userFeignService.findById(id);
    }


}
